using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Configuration;

namespace SIS.DAL.Utilities
{
    internal static class DBHelper
    {

        public static SqlConnection GetConnection()
        {
            return new SqlConnection(ConfigurationManager.ConnectionStrings["sis.dbconn"].ToString());
        }

        public static Nullable<T> DbNullToNullable<T>(object someObject) where T : struct
        {
            return (object.Equals(someObject, DBNull.Value)) ? (Nullable<T>)null : (T)Convert.ChangeType(someObject, typeof(T));
        }

        public static object NullableToDbNull<T>(Nullable<T> nullable) where T : struct
        {
            return (nullable.HasValue) ? (nullable.Value as object) : (DBNull.Value as object);
        }
    }
}
